package com.wocao.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wocao.entity.ReqBody;
import com.wocao.entity.ZyOwnerRoom;
import com.wocao.mapper.ZyOwnerRoomRecordMapper;
import com.wocao.service.ZyOwnerRoomService;
import com.wocao.mapper.ZyOwnerRoomMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

/**
 *
 */
@Service
public class ZyOwnerRoomServiceImpl extends ServiceImpl<ZyOwnerRoomMapper, ZyOwnerRoom> implements ZyOwnerRoomService{
    @Autowired
    private ZyOwnerRoomMapper zyOwnerRoomMapper;
    @Autowired
    private ZyOwnerRoomRecordMapper zyOwnerRoomRecordMapper;

    @Transactional
    @Override
    public void controlsOk(ReqBody reqBody) {
        zyOwnerRoomMapper.controlsOk(reqBody.getOwnerRoomId());
        zyOwnerRoomRecordMapper.controlsOk(reqBody.getOwnerRoomId(),reqBody.getOpinion(),reqBody.getUpdateBy(), LocalDateTime.now());
    }

    @Transactional
    @Override
    public void controlsNo(ReqBody reqBody) {
        zyOwnerRoomMapper.controlsNo(reqBody.getOwnerRoomId());
        zyOwnerRoomRecordMapper.controlsNo(reqBody.getOwnerRoomId(),reqBody.getOpinion(),reqBody.getUpdateBy(), LocalDateTime.now());
    }

    @Override
    public String getByuserId(String userId) {
        return zyOwnerRoomMapper.getByuserId(userId);
    }
}




